﻿Imports System.Net

Public Class frmPrincipal

    Private Sub btnConectar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConectar.Click
        ''listar
        CargarLista()

        ''Eliminar
        'Dim con As New ConexionFTP("localhost", "teje", "root", "21")
        'MessageBox.Show(con.DeleteFile("/uno - copia.txt"))

        ''Existe OK
        'Dim con As New ConexionFTP("localhost", "victor", "root", "21")
        'MessageBox.Show(con.ExistFile("/uno - copia.txt"))

        ''Crear directorio
        'Dim con As New ConexionFTP("localhost", "victor", "root", "21")
        'MessageBox.Show(con.CreateDirectory("teje"))

        ''Subir Archivo
        'Dim con As New ConexionFTP("localhost", "victor", "root", "21")
        'MessageBox.Show(con.UploadFile("C:\pruebasJava.txt", "/yosadf.txt", ""))

        ''Renombrar
        'Dim con As New ConexionFTP("localhost", "teje", "root", "21")
        'MessageBox.Show(con.RenameFile("/yosadf.txt", "/yosoytupadre.txt"))

        ''Descargar Archivo
        'Dim con As New ConexionFTP("localhost", "victor", "root", "21")
        'MessageBox.Show(con.DownloadFile("c:\youpdf", "/uno.txt"))
    End Sub

    Private Sub CargarLista()
        Dim con As New ConexionFTP("localhost", "victor", "root", "21")
        Dim lista As New List(Of String)
        Dim extension As String

        lista.Clear()
        lstLista.Items.Clear()


        lista.AddRange(con.ListFiles(""))

        For i As Integer = 0 To lista.Count - 1 Step 1
            lstLista.Items.Add(lista.Item(i))
            If con.isDirectory(lista.Item(i)) Then
                lstLista.Items(i).ImageKey = "carpeta.png"
            Else
                extension = lista(i).Substring((lista(i).Length - 3), 3)
                Select Case extension
                    Case "txt" : lstLista.Items(i).ImageKey = "archivo_texto.png"
                    Case "rar" : lstLista.Items(i).ImageKey = "archivo.png"
                End Select
            End If

        Next
    End Sub

    Private Sub frmPrincipal_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
        'Dim con As New ConexionFTP("localhost", "victor", "root", "21")

    End Sub
End Class

